package cn.yyljlyy.blog.admin.entity;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * 权限 entity
 * Created by Lijian on 2016/3/31.
 * @date 2016年3月31日
 */
@Entity
@Table(name = "lijpress_permission")
//@Cache(usage= CacheConcurrencyStrategy.READ_WRITE)
@DynamicUpdate
@DynamicInsert
public class Permission implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private Integer id;
	private Integer pid;
	private String text;
	private String type;
	private Integer sorting;
	private String url;
	private String icon;
	private String permCode;
	private String description;
	private String state;
	private List<Permission> children;


	/** default constructor */
	public Permission() {
	}

	/** minimal constructor */
	public Permission(String text) {
		this.text = text;
	}

	public Permission(Integer id) {
		this.id=id;
	}

	public Permission(Integer id, Integer pid, String text){
		this.id=id;
		this.pid=pid;
		this.text = text;
	}

	public Permission(Integer pid, String text, String type, String url, String permCode){
		this.pid=pid;
		this.text = text;
		this.type=type;
		this.url=url;
		this.permCode=permCode;
	}


	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "PID")
	public Integer getPid() {
		return this.pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}

	@Column(name = "TEXT", nullable = false, length = 50)
	public String getText() {
		return this.text;
	}

	public void setText(String text) {
		this.text = text;
	}

	@Column(name = "TYPE", length = 20)
	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Column(name = "SORTING")
	public Integer getSorting() {
		return this.sorting;
	}

	public void setSorting(Integer sorting) {
		this.sorting = sorting;
	}

	@Column(name = "URL")
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "ICON")
	public String getIcon() {
		return this.icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	@Column(name = "PERM_CODE", length = 50)
	public String getPermCode() {
		return this.permCode;
	}

	public void setPermCode(String permCode) {
		this.permCode = permCode;
	}

	@Column(name = "DESCRIPTION", length = 65535)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


	@Column(name = "STATE", length = 1)
	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	@Transient
	public List<Permission> getChildren() {
		return children;
	}

	public void setChildren(List<Permission> children) {
		this.children = children;
	}
}